package com.atguigu.exercise.user.controller;


import com.atguigu.exercise.user.entity.User;
import com.atguigu.exercise.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Durant
 * @since 2021-09-06
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService service;
    @ResponseBody
    @RequestMapping("/hello")
    public String hello(){
        return "hello world";
    }
    @RequestMapping("/success")
    public String success(Model model){
        User user = service.getById(1);
        model.addAttribute("user", user);

        return "success";
    }

}

